#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    long long maxScore(vector<int>& a, vector<int>& b) {
        int n = b.size();
        vector<vector<long long>> dp(n + 1, vector<long long>(5));
        for (int j = 1; j <= 4; j++) dp[0][j] = LLONG_MIN / 2;
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= 4; j++) {
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - 1] + (long long)a[j - 1] * b[i - 1]);
            }
        return dp[n][4];
    }
};